package com.acmen.easyapi.dbcp;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

/**
 * @Author acmen
 * @date 2022/8/21
 */
@Configuration
@EnableTransactionManagement
public class DataSourceConfig {
    public static final String DEFAULT_DATA_SOURCE_PREFIX = "spring.datasource";


    @Bean
    @ConfigurationProperties(prefix=DEFAULT_DATA_SOURCE_PREFIX)
    public DataSource dataSource() {
        return DataSourceBuilder.create().type(HikariDataSource.class).build();
    }


}
